package principe.singleresponsibility.singleresponsibility;

public class SingleResponsibility2 {
    public static void main(String[] args) {
        RoadVehicle roadVehicle = new RoadVehicle();

        roadVehicle.run("傻子");
        AirVehicle airVehicle = new AirVehicle();
        airVehicle.run("憨批");
    }
}

//方案2：
//1、遵守了单一职责原则
//2、需要做的改动很大，也就是类被修改，客户也需要修改
//3、改进：直接修改Vehicle类
class RoadVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "在公路上炸了");
    }
}

//class RoadVehicle{
//    public void run(String vehicle){
//
//    }
//}
class AirVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "在天空爆炸了");
    }
}

